package com.hitqz.robot.driver.util;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Multimap;
import com.google.common.collect.Table;

/**
 * @author xupkun
*  嵌入式协议
* */
public enum ProtocolUtils {


    SET_JACKING_DISTANCE(0xE2, 0x01, "设置顶升",  "MessageE201Handler"),

    SET_ROD_DISTANCE(0xE2, 0x02, "设置推杆", "MessageE202Handler"),

    SET_TOOL_DISTANCE(0xE2, 0x03, "设置工装切换", "MessageE203Handler"),

    SET_GRAPPER_DISTANCE(0xE2, 0x04, "设置抓夹距离", "MessageE204Handler"),

    SET_GRAPPER_ANGLE(0xE2, 0x05, "设置夹爪角度", "MessageE205Handler"),

    SET_LIGHT_STATUS(0xE2, 0x07, "设置补光灯", "MessageE207Handler"),

    SET_ROD_PRESSURE(0xE2, 0x11, "设置推杆压力", "MessageE211Handler"),
    SET_WALL_PRESSURE(0xE2, 0x12, "设置手扶墙压力", "MessageE212Handler"),




    QUERY_ALL_STATUS(0xE3, 0x01, "查询所有状态", "MessageE301Handler"),

    QUERY_PARAMS_STATUS(0xE3, 0x02, "查询所有状态", "MessageE302Handler"),

    RESET_GRAPPER_STATUS(0xE2,0x15, "复位电爪", "MessageE215Handler"),



    ;

    public static Multimap<Integer, Integer> MAIN_CMD_MAP = ArrayListMultimap.create();

    public static Table<Integer, Integer, ProtocolUtils> CMD_TABLE = HashBasedTable.create();

    static {
        for (ProtocolUtils value: values()) {
            ProtocolUtils.MAIN_CMD_MAP.put(value.getMainCmd(), value.getSubCmd());
            ProtocolUtils.CMD_TABLE.put(value.getMainCmd(), value.getSubCmd(), value);
        }
    }


    private final Integer mainCmd;

    private final Integer subCmd;

    private final String name;

    private final String packageName;

    ProtocolUtils(int mainCmd, int subCmd, String name, String packageName) {
        this.mainCmd = (byte) mainCmd & 0xff;
        this.subCmd = (byte) subCmd & 0xff;
        this.name = name;
        this.packageName = packageName;
    }

    public int getMainCmd() {
        return mainCmd;
    }

    public int getSubCmd() {
        return subCmd;
    }

    public String getName() {
        return name;
    }

    public String getPackageName() {
        return packageName;
    }


}
